//@author A0101906R
#include "stdafx.h"
#include "CppUnitTest.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace Twentyfifth;
using namespace std;

namespace UnitTest1 {
	TEST_CLASS(UnitTest1) {
public:

	TEST_METHOD(Task_SetDone) {   //test boundary case for initializing task, without spercifying, a task is by defaul to be not done
		// TODO: Your test code here
		Task t;
		Assert::AreEqual(false, t.isDone());
		t.setDone();
		Assert::AreEqual(true, t.isDone());
	}

	TEST_METHOD(Cmd_CmdEdit_Initialize) {   //Without specifying any detail, all attributes are set by default to be false.
		// TODO: Your test code here
		CmdEdit cmdedit;

		Assert::AreEqual(false, cmdedit.descEdited);
		Assert::AreEqual(false, cmdedit.startDateEdited);
		Assert::AreEqual(false, cmdedit.startTimeEdited);
		Assert::AreEqual(false, cmdedit.deadlineDateEdited);
		Assert::AreEqual(false, cmdedit.venueEdited);
	}

	TEST_METHOD(Cmd_getCmdType) {
		// TODO: Your test code here
		CmdEdit cmdedit;
		Cmd::CmdType ct = Cmd::EDIT;
		Assert::AreEqual(1, (int)cmdedit.getCmdType());
	}

	TEST_METHOD(Task_TaskType_Initialize) {   //without specifying, tasktype is set to be invalid.
		// TODO: Your test code here
		Task task;

		Assert::AreEqual(4, (int)task.getTaskType());
	}
	TEST_METHOD(Cmd_CmdExit_Execute) {
		// TODO: Your test code here
		CmdExit cmdexit;
		Status result;

		result = cmdexit.execution();
		Assert::AreEqual((int)Status::EXIT, (int)result.code);
	}
	/*
		TEST_METHOD(CmdAdd_StatusCodeToString) {
		//test case for StatusCodeToString, under cmdadd, default case should return task successfully added.
		CmdAdd cmdadd;
		Status result;
		string expected;

		result.code = Status::OK;
		expected = "Task successfully added.\n";
		Assert::AreEqual(expected, result.desc);
		}
		*/
	TEST_METHOD(System_Testing_For_Add_FloatingTask) {
		Logic logicComponent;
		Status statusFeedback;
		string userInput = "add system test.";
		string description = "system test.";
		string expectedFeedback = "Task successfully added.\n";

		statusFeedback = logicComponent.executeProgram(userInput);
		string feedback = statusFeedback.desc;
		size_t posFeedback = feedback.find(expectedFeedback);
		Assert::AreNotEqual(std::string::npos, posFeedback);
		userInput = "search test.";
		statusFeedback = logicComponent.executeProgram(userInput);
		Assert::AreEqual(false, statusFeedback.tasks[0].isDone());
		Assert::AreEqual(description, statusFeedback.tasks[0].getDescription());

	}

//	TEST_METHOD(System_Testing_For_Add_DeadlineTask) {
//		Logic logicComponent;
//		Status statusFeedback;
//		StorageMgr storage;
//		string userInput = "add system test 2. -deadline 24/04/2014";
//		string description = "system test 2.";
//		string expectedFeedback = "Task successfully added.\n";
//		Cmd cmd;
//		CmdDel cmddel;
//		int date;
//		DateTime dt;
////		dt.setToNow();
////		dt.offset(86400);
//		int expectedDate; // = dt.getDay(); // this needs to be fixed to make it truly automated.
//		statusFeedback = logicComponent.executeProgram(userInput);
//		string feedback = statusFeedback.desc;
//		size_t posFeedback = feedback.find(expectedFeedback);
//
//		userInput = "search test 2";
//		statusFeedback = logicComponent.executeProgram(userInput);
////		Assert::AreEqual(false, statusFeedback.tasks[0].isDone());
////		Assert::AreEqual(description, statusFeedback.tasks[0].getDescription());
//
//		date = ((statusFeedback.tasks[0]).getDeadline()).getDay();
//		dt = cmd.getCurrentDateTime();
//		dt.setDay(dt.getDay() + 1);
//		if(!dt.isValidDate()) {
//			dt.setDay(1);
//		}
//		expectedDate = dt.getDay();
////		Assert::AreNotEqual(std::string::npos, posFeedback);
////		Assert::AreEqual(expectedDate, date);
//
//		cmddel.setTask(statusFeedback.tasks[0]);
//		cmddel.execution();
//	}




	};
}